<template>
  <div class="box">
    <div
      id="today_yuQing_shuXing"
      class="today_yuQing_shuXing"
      :style="{width: '100%', height: '100%'}">
    </div>
  </div>
</template>

<script>
export default {
  name: "today_yuQing_shuXing",
  props: {
    yuQing_shuXing_data:{
      type: Array,
      required: true
    }
  },
  data() {
    return {
    }
  },
  mounted() {
    console.log("today_yuqing_shuxing--->",this.yuQing_shuXing_data)
    this.init_today_data_source()
  },
  methods: {
    // 获取数据
    getData() {

    },
    // 初始化
    init_today_data_source() {

      // let xArray=[]
      // let yArray=[]
      let yuQing_shuXing_data=[]
      for (let i = 0; i <this.yuQing_shuXing_data.length; i++) {
        yuQing_shuXing_data.push({name:this.yuQing_shuXing_data[i].emo,value:this.yuQing_shuXing_data[i].count})
        // yArray.push(this.yuQing_shuXing_data[i].count)
      }

      var dom = document.getElementById('today_yuQing_shuXing')
      var myChart = this.echarts.init(dom)
      // 绘制图表
      myChart.setOption({
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '5%',
          left: 'center',
          textStyle: {//图例文字的样式
            color: '#ccc',
            fontSize: 16
          }
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center',
              textStyle: {
                fontSize: 16,
                color: '#b0cefc'
              }
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '40',
                fontWeight: 'bold',
              }
            },
            labelLine: {
              show: false
            },
            data:yuQing_shuXing_data
            // data: [
            //   {value: 1048, name: '负面'},
            //   {value: 735, name: '中性'},
            //   {value: 580, name: '正面'},
            // ]
          }
        ]
      });
    }
  }
}
</script>

<style scoped>
.today_yuQing_shuXing {
  /*background-color: aliceblue;*/
  height: 240px;
}
.box{
  margin-top: 5px;
  margin-left: 5px;
  width: 370px;
  height: 215px;
}
</style>
